package com.handinfo.android.ui.window;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlTools;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWLabel;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

/**
 * 
 * 帮助界面
 * 
 * @author mujianchen
 * 
 */

public class UIHelp implements IUIWindows
{
	private DWFrame m_hFrame = null;
	private DWLabel m_hLabel = null;
	private Bitmap m_hBitmap01 = null;
	private Bitmap m_hBitmap02 = null;
	private Bitmap m_hBitmap04 = null;
	private Bitmap m_hBitmap_BJ = null;
	private DWTitle m_hTitle01 = null;
	private DWImageBox m_hImageBox01 = null;
	private DWImageBox m_hImageBox02 = null;
	private DWImageBox m_hImageBox_BJ = null;
	private DWBackground m_hBackground01 = null;
	private DWBackground m_hBackground02 = null;
	private DWBackground m_hBackground03 = null;
	private DWButton m_hButton01 = null;
	private DWTextbox m_hTextbox01 = null;

	public void init()
	{
		m_hBitmap01 = UIWindows.createImage("/img/newui/denglubjt_1.gnp");
		m_hBitmap02 = UIWindows.createImage("/img/newui/anniu_6.gnp");
		m_hBitmap04 = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		m_hBitmap_BJ = UIWindows.createImage("/img/newui/youxibangzhu_1.gnp");
	}

	private void help()
	{
		if (m_hFrame != null) {
			DWControlsManager.getInstance().removeControl(m_hFrame);
		}
		m_hFrame = new DWFrame(DWGameManager.Screen_Width, DWGameManager.Screen_Height);
		m_hImageBox01 = new DWImageBox(m_hBitmap01, DWGameManager.Screen_Width, DWGameManager.Screen_Height);
		m_hImageBox01.setNearAnchor(m_hFrame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

		
		
		m_hBackground01 = new DWBackground(m_hBitmap01, 0, 0, m_hFrame.getShowWidth(),
				m_hFrame.getShowHeight());
		m_hBackground01.setNearAnchor(m_hFrame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

		m_hBackground03 = new DWBackground(m_hFrame.getShowWidth() - 200,
				m_hFrame.getShowHeight() - 150);
		m_hBackground03.setNearAnchor(m_hFrame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

		m_hTitle01 = new DWTitle("", m_hFrame);
		m_hTitle01.setNearAnchor(m_hBackground03, Tools.LEFT_TOP, Tools.LEFT_TOP);
		m_hTitle01.setShowWideHigh(m_hBackground03.getShowWidth(), 35);

		m_hImageBox_BJ = new DWImageBox(m_hBitmap_BJ);
		m_hImageBox_BJ.setNearAnchor(m_hTitle01, Tools.HCENTER_TOP, Tools.HCENTER_TOP);
		
//		m_hLabel = new DWLabel("游戏帮助");
//		m_hLabel.setTextColor(Tools.YELLOW);
//
//		m_hBackground02 = new DWBackground(m_hBitmap05, 0, 0, m_hBackground03
//				.getShowWidth(), m_hLabel.getShowHeight() + 10);
//		m_hBackground02.setNearAnchor(m_hBackground03, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 10);
//		m_hFrame.addControl(m_hBackground02);
//
//		m_hLabel.setNearAnchor(m_hBackground02, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
//		m_hFrame.addControl(m_hLabel);

		m_hButton01 = new DWButton("返回登录", m_hBitmap02);
		m_hButton01.setDownImage(m_hBitmap04);
		m_hButton01.addListener(r_fanhui_lis);
		m_hButton01.setNearAnchor(m_hBackground03,  Tools.RIGHT_TOP,
				Tools.LEFT_BOTTOM, m_hButton01.getShowWidth() / 2, 10);

		m_hTextbox01 = new DWTextbox("想了解更多的详情，请直接登陆我们的官网" 
				+ DWControlTools.CHANGE_ROW 
				+ "地址：www.dreamworks.net.cn" 
				+ DWControlTools.CHANGE_ROW
				+ "联系电话：400-061-1230",
				Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 450);
		m_hTextbox01.setNearAnchor(m_hBackground03, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

		m_hFrame.addControl(m_hImageBox01);
		m_hFrame.addControl(m_hBackground01);
		m_hFrame.addControl(m_hBackground03);
		m_hFrame.addControl(m_hTitle01);
		m_hFrame.addControl(m_hImageBox_BJ);
//		m_hFrame.addControl(m_hLabel);
		m_hFrame.addControl(m_hButton01);
		m_hFrame.addControl(m_hImageBox02);
		m_hFrame.addControl(m_hTextbox01);

		DWControlsManager.getInstance().addControl(m_hFrame);
	}

	private DWListener r_fanhui_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{

			DWControlsManager.getInstance().removeControl(m_hFrame);
			close((byte) 0);
		}
	};

	public void open(byte index)
	{
		help();
	}

	public void close(byte index)
	{
		DWControlsManager.getInstance().removeControl(m_hFrame);
	}

	public void dispose()
	{

	}

	public void logic()
	{

	}
}
